import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;

/**
 * Created with IntelliJ IDEA.
 * User: thoughtworker
 * Date: 10/10/13
 * Time: 7:31 PM
 * To change this template use File | Settings | File Templates.
 */
public class playerRepository {

    private Collection<Player> listOfPlayers = new ArrayList<Player>();
    private PrintStream printer;

    public playerRepository(PrintStream printer, Collection<Player> listOfPlayers) {
        this.printer = printer;
        this.listOfPlayers = listOfPlayers;
    }

    public void displayInfoOfAllPlayers() {
        for(Player player : listOfPlayers) {
            player.displayPlayerInfo(printer);
        }
    }

    public Player findPlayerByName(String nameOfPlayerToFind) {
        for(Player player : listOfPlayers) {
            if(player.getName().equals(nameOfPlayerToFind)) {
                player.displayPlayerInfo(printer);
                return player;
            }
        }
        return null;
    }
}
